using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vPOSMap : EntityTypeConfiguration<vPOS>
    {
        public vPOSMap()
        {
            // Primary Key
            this.HasKey(t => new { t.CustCurrency, t.DocCurrency, t.DocDate });

            // Properties
            this.Property(t => t.CustID)
                .HasMaxLength(6);

            this.Property(t => t.CustomerName)
                .HasMaxLength(110);

            this.Property(t => t.CashCustomerName)
                .HasMaxLength(35);

            this.Property(t => t.CustCurrency)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.DocCurrency)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.DocNumber)
                .HasMaxLength(8);

            this.Property(t => t.Notes)
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("vPOS");
            this.Property(t => t.CustID).HasColumnName("CustID");
            this.Property(t => t.CustomerName).HasColumnName("CustomerName");
            this.Property(t => t.CashCustomerName).HasColumnName("CashCustomerName");
            this.Property(t => t.CustCurrency).HasColumnName("CustCurrency");
            this.Property(t => t.DocCurrency).HasColumnName("DocCurrency");
            this.Property(t => t.PSID).HasColumnName("PSID");
            this.Property(t => t.Doctype).HasColumnName("Doctype");
            this.Property(t => t.DocPrimaryKey).HasColumnName("DocPrimaryKey");
            this.Property(t => t.DocNumber).HasColumnName("DocNumber");
            this.Property(t => t.DocDate).HasColumnName("DocDate");
            this.Property(t => t.doc_ref).HasColumnName("doc_ref");
            this.Property(t => t.Total).HasColumnName("Total");
            this.Property(t => t.timestmp).HasColumnName("timestmp");
            this.Property(t => t.closedout).HasColumnName("closedout");
            this.Property(t => t.posted).HasColumnName("posted");
            this.Property(t => t.Notes).HasColumnName("Notes");
            this.Property(t => t.IsOpening).HasColumnName("IsOpening");
        }
    }
}
